package com.grf.hadoop.same_friend;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class FriendReducer extends Reducer<Text, Text, Text, Text> {

    private Text v = new Text();

    @Override
    protected void reduce(Text key, Iterable<Text> values, Context context)
            throws IOException, InterruptedException {
        //key 是好友， value是拥有该好友的用户
        String users = "";
        for (Text value : values) {
            users += value;
        }
        v.set(users);
        context.write(key, v);
    }
}
